/*
 * @Descripttion: 
 * @Author: junhuafly
 * @Date: 2020-03-12 11:37:24
 * @LastEditors: junhuafly
 * @Email: junhuafly@163.com
 * @LastEditTime: 2020-03-19 10:15:46
 */
const {
    request
} = require('./../utils/request.js')
const header = {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
}
class User {

    /**
     * 操作关注用户
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    handleFollowUser(data) {
        return request.post(data.follow ? '/customer/follow' : '/customer/undoFollow', data)
    }

    /**
     * 检查是否关注
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    hasFollowed(data) {
        return request.get("/customer/isFollowed", data)
    }

    /**
     * 获取用户个人信息
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    queryCustomerInfos(data){
        return request.get('/customer/info',data)
    }

    /**
     * 查询该用户下的所有笔记
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    queryCustomerNotes(data){
        return request.post('/note/query',data)
    }

    /**
     * 获取消息提醒
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    queryCustomerMsg(data){
        return request.get('/remind/my/list',data)
    }

    /**
     * 更新用户信息背景墙
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    putCustomerInfosBgWall(data){
        return request.put('/customer/personalBackgroundUrl',data)
    }

    /**
     * 拉黑用户
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    joinBlackUser(data){
        return request.post('/block/user',data,header)
    }

    /**
     * 获取用户个人面板信息
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    queryCustomer(data){
        return request.get('/customer',data,header)
    }

    /**
     * 获取所有标签信息
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    queryTagByAll(data){
        return request.get('/tag',data)
    }

    /**
     * 操作用户标签
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    handleCustomerTags(data){
        return request[data?'put':'get']('/customer/tag',data)
    }

    /**
     * 检查用户状态
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    checkCustomerStatus(data){
        return request.get('/users/check/status',data)
    }

    /**
     * 修改用户资料信息
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    updateCustomerInfo(data){
        return request.put('/users',data)
    }

    /**
     * 获取用户地址
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    queryCustomerAddress(data){
        return request.get('/customer/address',data)
    }

    /**
     * 操作用户地址信息
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    handleCustomerAddress(data){
        return request[data['method']](`/customer/address${data.method==="delete"?"?addressId="+data.addressId:""}`,data)
    }

    /**
     * 获取优惠券信息
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    queryCustomerCoupons(data){
        return request.get('/customer/coupon',data)
    }

    /**
     * 获取用户粉丝
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    queryCustomerFans(data){
        return request.get('/customer/fans',data)
    }

    /**
     * 获取用户的关注
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    queryCustomerFollow(data){
        return request.get('/customer/follows',data)
    }

    /**
     * 获取推荐关注的用户列表
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    queryCustomerRecommendFollow(data){
        return request.post('/customer/recommend/list',data)
    }

    /**
     * 获取获赞列表
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    queryCustomerLikeMe(data){
        return request.post('/customer/likeMe',data)
    }

    /**
     * 关注用户
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    followCustomer(data){
        return request.post('/customer/follow',data)
    }

    /**
     * 取消关注用户
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    unFollowCustomer(data){
        return request.post('/customer/undoFollow',data)
    }

    /**
     * 获取钱包信息
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    queryWallet(data){
        return request.get('/customer/wallet',data)
    }

    /**
     * 用户反馈
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    handleFeedBack(data){
        return request.post('/feedback/create',data)
    }

    /**
     * 获取用户黑名单
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    queryUserBlock(data){
        return request.get('/block/user',data)
    }

    /**
     * 移除黑名单
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    removeBlock(data){
        return request.get('/block/user/release',data)
    }


    // 以下是登錄相關

    /**
     * 客户登录
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    login(data){
        return request.post(`/login/mini/${data.code}`,data)
    }

    /**
     * 获取sessionKey
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    getSessionKey(data){
        return request.get(`/sessionKey/send/${data.code}`)
    }

    /**
     * 发送验证码
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    sendSms(data){
        return request.post('/sms/send',data)
    }

    /**
     * 手机登录
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf User
     */
    loginByPhone(data){
        return request.post('/login/phone',data)
    }
   
}
exports.userAPI = new User